package vip.aster.common.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 通用状态枚举类
 *
 * @author Aster
 * @since 2023/11/30 15:48
 */
@Getter
public enum StatusEnum {
    /**
     * 启用
     */
    ENABLE("0", "启用"),
    /**
     * 冻结
     */
    DISABLE("1", "冻结");


    private final String code;
    private final String text;

    StatusEnum(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public static String getCode(String text) {
        StatusEnum[] enums = StatusEnum.values();
        for (StatusEnum bEnum : enums) {
            if (bEnum.getText().equals(text)) {
                return bEnum.getCode();
            }
        }
        return null;
    }

    public static String getText(String code) {
        StatusEnum[] enums = StatusEnum.values();
        for (StatusEnum bEnum : enums) {
            if (bEnum.getCode().equals(code)) {
                return bEnum.getText();
            }
        }
        return null;
    }
}
